package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/29.
 */
@HttpInlet(Conn.INLET_API_CLAIMS_RESULT)
public class GetApiLiPeiResult extends BaseAsyGet<GetApiLiPeiResult.SearchInfo> {

    public String tid, cid, policynum, idnum, name, userid, phone, vehicle_license;

    public GetApiLiPeiResult(AsyCallBack<SearchInfo> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected SearchInfo parser(JSONObject object) {

        TOAST = object.optString("message");

        if (object.optInt("code") == 200) {

            SearchInfo searchInfo = new SearchInfo();

            searchInfo.count = object.optString("count");

            JSONArray array = object.optJSONArray("data");

            if (array != null) {

                for (int i = 0; i < array.length(); i++) {

                    JSONObject dataObject = array.optJSONObject(i);

                    Data data = new Data();

                    data.accidentdate = dataObject.optString("accidentdate");
                    data.title = dataObject.optString("title");
                    data.address = dataObject.optString("address");
                    data.tid = dataObject.optString("tid");
                    data.price = dataObject.optString("price");

                    searchInfo.enetiyLists.add(data);
                }


            }

            return searchInfo;

        }

        return null;
    }

    public static class SearchInfo implements Serializable {

        public String count;

        public List<Data> enetiyLists = new ArrayList<>();

    }

    public static class Data implements Serializable {

        public String accidentdate, title, address, tid, price;

    }

}
